import { Component, OnInit, Input } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Http } from '@angular/http';

@Component({
  selector: 'app-list',
  templateUrl: './list.component.html',
  styleUrls: ['./list.component.css']
})
export class ListComponent implements OnInit {
  @Input()
  ths: Array<string>;
  @Input()
  url: string;

  public observable: Observable<any>;

  public trs: GetSPFV[ ];
  constructor(public http: Http) { }

  ngOnInit() {
    this.observable = this.http.get(this.url).map( res => res.json() );
    this.observable.subscribe(
      data => {
        console.log(JSON.parse(data));
        this.trs = JSON.parse(data).data;
      },
      err => console.log(err)
    );
  }

}

export class GetSPFV {
  ID: number;
  DataType: string;
  BeginTime: string;
  EndTime: string;
  Charge: number;
}
